//
//  WDJLunPanView.m
//  wdj
//
//  Created by 蓝鳍互娱 on 2024/7/9.
//

#import "WDJLunPanView.h"
#import "ORRingChartView.h"

@interface WDJLunPanView()<ORRingChartViewDatasource>
@property (nonatomic, strong) ORRingChartView *ringChartView;
@end
@implementation WDJLunPanView
-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = UIColor.clearColor;
        [self wdjCreatView];
    }
    return self;
}
- (void)wdjCreatView{
    _ringChartView = [[ORRingChartView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
    _ringChartView.dataSource = self;
    _ringChartView.config.ringWidth = 1;
    _ringChartView.style = ORRingChartStylePie;
    [self addSubview:_ringChartView];
}
-(void)setLunPans:(NSArray *)lunPans{
    _lunPans = lunPans;
    for (UIView * subView in _ringChartView.subviews) {
        [subView removeFromSuperview];
    }
    [_ringChartView reloadData];
}
- (NSInteger)numberOfRingsOfChartView:(ORRingChartView *)chartView {
    return self.lunPans.count;
}
- (CGFloat)chartView:(ORRingChartView *)chartView valueAtRingIndex:(NSInteger)index {
    return 50;
}
- (UIView *)chartView:(ORRingChartView *)chartView viewForRingInfoAtRingIndex:(NSInteger)index {
//    UILabel *lunPanZhLab = [chartView dequeueRingInfoViewAtIndex:index];
//    if (!lunPanZhLab) {
    UILabel * lunPanZhLab = [[UILabel alloc] init];
        lunPanZhLab.font = [UIFont systemFontOfSize:[WDjWholeData wholeScreewRatio:24] weight:UIFontWeightMedium];
        lunPanZhLab.textColor = [WDjWholeData wholeColorHexString:@"#FFFFFF"];
        lunPanZhLab.numberOfLines = 0;
//    }
    lunPanZhLab.text = self.lunPans[index];
    [lunPanZhLab sizeToFit];
    return lunPanZhLab;
}

//- (CGFloat)chartView:(ORRingChartView *)chartView pointWidthForInfoLineAtRingIndex:(NSInteger)index {
//    return self.lunPans.count;
//}
//// 生成随机颜色
//- (UIColor *)wdjRandomColor {
//    CGFloat red = (arc4random() % 256) / 255.0; // 生成0-1之间的随机红色分量
//    CGFloat green = (arc4random() % 256) / 255.0; // 生成0-1之间的随机绿色分量
//    CGFloat blue = (arc4random() % 256) / 255.0; // 生成0-1之间的随机蓝色分量
//    return [UIColor colorWithRed:red green:green blue:blue alpha:1.0];
//}
//#pragma mark -- UICollectionViewDelegate
//- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
//    return 10; // 设置10个item
//}
//- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
//    WDJLunPanCollectionCell *lunPanCollectionCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"WDJLunPanCollectionCell" forIndexPath:indexPath];
//    lunPanCollectionCell.lunPanTitle = [NSString stringWithFormat:@"%zd",indexPath.row+1];
//    lunPanCollectionCell.backgroundColor = [self wdjRandomColor];
//    return lunPanCollectionCell;
//}
@end
